<?php 

class DB_lang extends DB {

    public function __construct() {

        global $CONFIG;

        if (!self::$instance) {

            $CONFIG->db_lang_host = $CONFIG->db_host;
//	        $CONFIG->db_lang_host = str_replace($CONFIG->db_prefixadapter, $CONFIG->db_prefixadapter.$_SESSION['lang'], $CONFIG->db_host);

	        $CONFIG->db_lang_user = $CONFIG->db_user.$_SESSION['lang'];
	        $CONFIG->db_lang_pass = $CONFIG->db_pass.$_SESSION['lang'];
	        $CONFIG->db_lang_name = $CONFIG->db_name.$_SESSION['lang'];
	        
	        try {
	            $this->instance = new PDO("mysql:host=".$CONFIG->db_lang_host.";dbname=".$CONFIG->db_lang_name, $CONFIG->db_lang_user, $CONFIG->db_lang_pass);
	            $this->instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	        } catch (Exception $e) {
	        	if ($CONFIG->debug) {
	        	    die('DB_lang connection error');
	        	}
	        }
        }

        return $this->instance;
    }
}
